#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using i128 = __int128;
const int N = 1e6 + 5;

string n;

int num(int l, int r) {
    int sign = 1;
    int ans = 0;
    int i = l;
    if(n[i] == '-') {
        sign = -1;
        i++;
    }
    for (; i <= r; i++) {
        ans = ans * 10 + n[i] - '0';
    }
    return ans * sign;
}

int cale(int l, int r) {
    if (l > r) return 0;
    int cnt = 0, add = 0, mul = 0, power = 0;
    bool fu = false;
    if (n[l] == '-' && l < r){
        fu = true;
        int val = cale(l+1, r);
        return -val;
    }
    for (int i = l; i <= r; i++) {
        if (n[i] == '(')
            cnt++;
        else if (n[i] == ')')
            cnt--;
        else if (!cnt) {
            switch (n[i]) {
                case '+':
                case '-':
                    if (i > l && (isdigit(n[i - 1]) || n[i - 1] == ')')) {
                        add = i;
                    }
                    break;
                case '*':
                case '/':
                    mul = i;
                    break;
                case '^':
                    power = i;
                    break;
            }
        }
    }
    if (cnt > 0 && n[l] == '(') {
        return cale(l + 1, r);
    } else if (cnt < 0 && n[r] == ')') {
        return cale(l, r - 1);
    } else if (!cnt && !add && !mul && !power) {
        if (n[l] == '(' && n[r] == ')') return cale(l + 1, r - 1);
        return num(l, r);
    }
    if (add) {
        if (n[add] == '+')
            return cale(l, add - 1) + cale(add + 1, r);
        else
            return cale(l, add - 1) - cale(add + 1, r);
    }
    if (mul) {
        if (n[mul] == '*')
            return cale(l, mul - 1) * cale(mul + 1, r);
        else
            return cale(l, mul - 1) / cale(mul + 1, r);
    }
    if (power) {
        return pow(cale(l, power - 1), cale(power + 1, r));
    }
    return num(l, r);
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cin >> n;
    cout << cale(0, n.length() - 1) << endl;

    return 0;
}